<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>清除定时器的使用</title>
</head>
<body>
<div id="clock"></div>
</body>
<script>
    let element = document.getElementById('clock');
    let timer = setInterval(function () {
        let time = new Date();
        // console.log(time);
        element.innerText = time.toLocaleTimeString()
    }, 1000)
    setTimeout(function () {
        clearInterval(timer)
        element.innerText = "计时器终止服务"
    }, 10000)
</script>
</html>